<div th:fragment="html">
    <script>
        $(function(){
            var data4Vue = {
                uri:'forelogin',
                result: [],
                user:{username:'', password:''}
            };
            //ViewModel
            var vue = new Vue({
                el: '#workingArea',
                data: data4Vue,
                mounted:function(){

                },
                methods: {
                    login:function(){
                        var url =  this.uri;
                        if(0==this.user.username.length){
                            $("span.errorMessage").html("请输入您的邮箱");
                            $("div.registerErrorMessageDiv").css("visibility","visible");
                            return;
                        }
                        if(0==this.user.password.length){
                            $("span.errorMessage").html("请输入密码");
                            $("div.registerErrorMessageDiv").css("visibility","visible");
                            return;
                        }


                        axios.post(url,this.user).then(function(response) {
                            var result = response.data;
                            if(result.code==0){
                                alert("登录成功");
                                if(result.data=="初级用户")
                                {
                                    sessionStorage.jwt = 123;
                                    location.href="admin_useinfo";

                                }

                                if(result.data=="高级用户")
                                {
                                    sessionStorage.jwt = 456;
                                    location.href="admin_fixture";
                                }

                                if(result.data=="系统管理员")
                                {
                                    sessionStorage.jwt = 789;
                                    location.href="admin_user";
                                }
                            }
                            else{
                                $("span.errorMessage").html(result.message);
                                $("div.registerErrorMessageDiv").css("visibility","visible");
                            }
                        });
                    }
                }
            });
        })
    </script>
    <div class="page login-page" id="workingArea">
        <div class="container d-flex align-items-center">
            <div class="form-holder has-shadow">
                <div class="row">
                    <!-- Logo & Information Panel-->
                    <div class="col-lg-6">
                        <div class="info d-flex align-items-center">
                            <div class="content">
                                <div class="logo">
                                    <h1>TMS</h1>
                                </div>
                                <p>工夹具全寿命智能管理系统</p>
                            </div>
                        </div>
                    </div>

                    <!-- Form Panel    -->
                    <div class="col-lg-6 bg-white">

                        <div class="form d-flex align-items-center">

                            <div class="content">

                                <div class="registerErrorMessageDiv">
                                    <div class="alert alert-info" role="alert">
                                        <button type="button" class="close" data-dismiss="alert" aria-label="Close"></button>
                                        <span class="errorMessage"></span>
                                    </div>
                                </div>

                                <table class="loginTable">
                                    <tr>
                                        <td>
                                            <div class="form-group">
                                                用户名
                                            </div>
                                        </td>
                                        <td>
                                            <div class="form-group">
                                                <input v-model="user.username" placeholder="请输入您的用户名" class="input-material">
                                            </div>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <div class="form-group">
                                                密码
                                            </div>
                                        </td>
                                        <td>
                                            <div class="form-group">
                                                <input v-model="user.password"  type="password"  placeholder="请输入您的密码" class="input-material">
                                            </div>
                                        </td>
                                    </tr>
                                </table>
                                <div class="form-group" align="center">
                                    <button  @click="login" type="submit" class="btn btn-primary">登录</button>
                                </div>

                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>


    </body>
</div>